<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" 
xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:jpdl="http://jbpm.org/4.3/jpdl" xmlns:svg="http://www.w3.org/2000/svg">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	
	<xsl:template match="jpdl:process">
		<svg:svg>
			<svg:defs>
				<svg:marker id="Triangle" refX="70" refY="7" markerUnits="userSpaceOnUse" 
						markerWidth="20" markerHeight="10" orient="auto" overflow="visible" fill="green">
               		<svg:path d="M 0 0 L 14 7 L 0 14 z"/>
          		</svg:marker> 
			</svg:defs>

			<svg:g>
				<xsl:apply-templates select="//jpdl:transition"/>
	  			<xsl:apply-templates select="jpdl:start"/>
	  			<xsl:apply-templates select="jpdl:end"/>
	  			<xsl:apply-templates select="jpdl:end-cancel"/>
	  			<xsl:apply-templates select="jpdl:end-error"/>
	  			<xsl:apply-templates select="jpdl:state"/>
	  			<xsl:apply-templates select="jpdl:java"/>
	  			<xsl:apply-templates select="jpdl:task"/>
	  			<xsl:apply-templates select="jpdl:script"/>
	  			<xsl:apply-templates select="jpdl:hql"/>
	  			<xsl:apply-templates select="jpdl:sub-process"/>
	  			<xsl:apply-templates select="jpdl:decision"/>
	  			<xsl:apply-templates select="jpdl:join"/>
	  			<xsl:apply-templates select="jpdl:rule"/>
	  			<xsl:apply-templates select="jpdl:fork"/>
	  		</svg:g>

		</svg:svg>
	</xsl:template>
<!-- 	
	<xsl:template match="jpdl:*[@active='true']">
		<xsl:variable name="x">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="1"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="y">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="2"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="w">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="3"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="h">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="4"/>
			</xsl:call-template>
		</xsl:variable>
		
		<svg:rect x="{$x}" y="{$y}" width="{$w}" height="{$h}" rx="10" ry="10" style="fill-opacity:0.5;stroke:red; stroke-width:4;"/>
		
	</xsl:template>
 -->
	<xsl:template match="jpdl:start">
	
		<xsl:variable name="x">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="1"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="y">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="2"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="w">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="3"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="h">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="4"/>
			</xsl:call-template>
		</xsl:variable>
		
		<svg:circle cx="{$x + 20}" cy="{$y + 20}" r="20" style="fill:lightgreen; "/>
		<xsl:choose>
			<xsl:when test="@active='true'">
				<svg:circle cx="{$x + 20}" cy="{$y + 20}" r="20" style="stroke:red; opacity:1; fill:none; stroke-width:4;"/>
			</xsl:when>
			<xsl:otherwise>
				<svg:circle cx="{$x + 20}" cy="{$y + 20}" r="20" style="stroke:darkgreen; opacity:1; fill:none; stroke-width:2;"/>
			</xsl:otherwise>
		</xsl:choose>
		
	</xsl:template>
	
	<xsl:template match="jpdl:end">
		
		<xsl:variable name="x">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="1"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="y">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="2"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="w">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="3"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="h">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="4"/>
			</xsl:call-template>
		</xsl:variable>

		<svg:circle cx="{$x + 20}" cy="{$y + 20}" r="20" style="fill:lightpink;"/>
		<svg:circle cx="{$x + 20}" cy="{$y + 20}" r="11" style="fill:darkred; stroke:darkred; opacity:1; stroke-width:2;"/>
		
		<xsl:choose>
			<xsl:when test="@active='true'">
				<svg:circle cx="{$x + 20}" cy="{$y + 20}" r="20" style="stroke:red; opacity:1; fill:none; stroke-width:4;"/>
			</xsl:when>
			<xsl:otherwise>
				<svg:circle cx="{$x + 20}" cy="{$y + 20}" r="20" style="stroke:black; opacity:1; fill:none; stroke-width:2;"/>
			</xsl:otherwise>
		</xsl:choose>
			
	</xsl:template>
	
	<xsl:template match="jpdl:end-cancel">
		
		<xsl:variable name="x">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="1"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="y">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="2"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="w">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="3"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="h">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="4"/>
			</xsl:call-template>
		</xsl:variable>

		<svg:circle cx="{$x + 20}" cy="{$y + 20}" r="20" style="fill:lightpink;"/>
		<xsl:choose>
			<xsl:when test="@active='true'">
				<svg:circle cx="{$x + 20}" cy="{$y + 20}" r="20" style="stroke:red; opacity:1; fill:none; stroke-width:4;"/>
			</xsl:when>
			<xsl:otherwise>
				<svg:circle cx="{$x + 20}" cy="{$y + 20}" r="20" style="stroke:black; opacity:1; fill:none; stroke-width:2;"/>
			</xsl:otherwise>
		</xsl:choose>
		<svg:text x="{$x + 20}" y="{$y + 36}" font-size="46"  
			text-anchor="middle" fill="darkred" stroke="darkred" font-family="Arial" font-weight="bold" transform="rotate(45 {$x + 20} {$y + 20})">+</svg:text>
		
	</xsl:template>
	
	<xsl:template match="jpdl:end-error">
		
		<xsl:variable name="x">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="1"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="y">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="2"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="w">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="3"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="h">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="4"/>
			</xsl:call-template>
		</xsl:variable>

		<svg:circle cx="{$x + 20}" cy="{$y + 20}" r="20" style="fill:lightpink;"/>
		
		<xsl:choose>
			<xsl:when test="@active='true'">
				<svg:circle cx="{$x + 20}" cy="{$y + 20}" r="20" style="stroke:red; opacity:1; fill:none; stroke-width:4;"/>
			</xsl:when>
			<xsl:otherwise>
				<svg:circle cx="{$x + 20}" cy="{$y + 20}" r="20" style="stroke:black; opacity:1; fill:none; stroke-width:2;"/>
			</xsl:otherwise>
		</xsl:choose>
		
		<svg:g transform="translate({$x + 7},{$y + 2})">
			<svg:g transform="scale(0.25)">  
				<svg:polygon stroke="#F99D1C" fill="darkred"
					points="68.229,0.807 54.798,46.389 42.355,38.759 29.714,81.329 19.838,74.1 0.481,142.775 41.169,90.165 49.268,96.188 71.192,58.036 78.697,64.06 107.732,28.317"/>
			</svg:g>
		</svg:g>
	</xsl:template>
	
	<xsl:template match="jpdl:decision">
		
		<xsl:variable name="x">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="1"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="y">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="2"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="w">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="3"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="h">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="4"/>
			</xsl:call-template>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="@active='true'">
				<svg:rect x="{$x}" y="{$y}" width="40" height="40" style="fill:palegoldenrod; stroke:red; stroke-width:4;"
					transform="rotate(45 {$x + 20} {$y + 20})"/>
			</xsl:when>
			<xsl:otherwise>
				<svg:rect x="{$x}" y="{$y}" width="40" height="40" style="fill:palegoldenrod; stroke:gold; stroke-width:2;"
					transform="rotate(45 {$x + 20} {$y + 20})"/>
			</xsl:otherwise>
		</xsl:choose>

		<svg:text x="{$x + 20}" y="{$y + 36}" font-size="46"  
			text-anchor="middle" fill = "olive" font-family="Arial" font-weight="bold" transform="rotate(45 {$x + 20} {$y + 20})">+</svg:text>
		
	</xsl:template>
	
	<xsl:template match="jpdl:rule">
		
		<xsl:variable name="x">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="1"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="y">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="2"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="w">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="3"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="h">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="4"/>
			</xsl:call-template>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="@active='true'">
				<svg:rect x="{$x}" y="{$y}" width="40" height="40" style="fill:palegoldenrod; stroke:red; stroke-width:4;"
					transform="rotate(45 {$x + 20} {$y + 20})"/>
			</xsl:when>
			<xsl:otherwise>
				<svg:rect x="{$x}" y="{$y}" width="40" height="40" style="fill:palegoldenrod; stroke:gold; stroke-width:2;"
					transform="rotate(45 {$x + 20} {$y + 20})"/>			
			</xsl:otherwise>
		</xsl:choose>
		<svg:text x="{$x + 20}" y="{$y + 36}" font-size="46"  
			text-anchor="middle" fill = "olive" font-family="Arial" font-weight="bold" transform="rotate(45 {$x + 20} {$y + 20})">+</svg:text>
		
	</xsl:template>
	
	<xsl:template match="jpdl:join">
		
		<xsl:variable name="x">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="1"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="y">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="2"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="w">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="3"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="h">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="4"/>
			</xsl:call-template>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="@active='true'">
				<svg:rect x="{$x}" y="{$y}" width="40" height="40" style="fill:palegoldenrod; stroke:red; stroke-width:4;"
					transform="rotate(45 {$x + 20} {$y + 20})"/>
			</xsl:when>
			<xsl:otherwise>
				<svg:rect x="{$x}" y="{$y}" width="40" height="40" style="fill:palegoldenrod; stroke:gold; stroke-width:2;"
					transform="rotate(45 {$x + 20} {$y + 20})"/>
			</xsl:otherwise>
		</xsl:choose>

		<svg:text x="{$x + 20}" y="{$y + 37}" font-size="46"  
				text-anchor="middle" fill = "olive" font-family="Arial" font-weight="bold" >+</svg:text>
		
	</xsl:template>
	
	<xsl:template match="jpdl:fork">
		
		<xsl:variable name="x">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="1"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="y">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="2"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="w">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="3"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="h">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="4"/>
			</xsl:call-template>
		</xsl:variable>
		
		<xsl:choose>
			<xsl:when test="@active='true'">
				<svg:rect x="{$x}" y="{$y}" width="40" height="40" style="fill:palegoldenrod; stroke:red; stroke-width:4;"
					transform="rotate(45 {$x + 20} {$y + 20})"/>
			</xsl:when>
			<xsl:otherwise>
				<svg:rect x="{$x}" y="{$y}" width="40" height="40" style="fill:palegoldenrod; stroke:gold; stroke-width:2;"
					transform="rotate(45 {$x + 20} {$y + 20})"/>
			</xsl:otherwise>
		</xsl:choose>

		<svg:text x="{$x + 20}" y="{$y + 37}" font-size="46"  
				text-anchor="middle" fill = "olive" font-family="Arial" font-weight="bold" >+</svg:text>
		
	</xsl:template>
	
	<xsl:template match="jpdl:state">

		<xsl:variable name="x">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="1"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="y">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="2"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="w">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="3"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="h">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="4"/>
			</xsl:call-template>
		</xsl:variable>
		
		<xsl:choose>
			<xsl:when test="@active='true'">
				<svg:rect x="{$x}" y="{$y}" width="{$w}" height="{$h}" rx="10" ry="10" style="fill:lavender; stroke:red; stroke-width:4;"/>
			</xsl:when>
			<xsl:otherwise>
				<svg:rect x="{$x}" y="{$y}" width="{$w}" height="{$h}" rx="10" ry="10" style="fill:lavender; stroke:steelblue; stroke-width:2;"/>
			</xsl:otherwise>
		</xsl:choose>
		<svg:text  x="{$x + $w div 2}" y="{$y + $h div 2}" dx="0,0,0,0,20" dy="0,0,0,0,8" rotate="20,30,40,50,0,0,-10" 
			textLength="{$w}" lengthAdjust="spacing" font-size="16"  text-anchor="middle" fill = "navy" font-family="Arial">
			<xsl:value-of select="@name"/>
		</svg:text>
		
	</xsl:template>
	
	<xsl:template match="jpdl:java">

		<xsl:variable name="x">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="1"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="y">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="2"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="w">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="3"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="h">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="4"/>
			</xsl:call-template>
		</xsl:variable>
		
		<xsl:choose>
			<xsl:when test="@active='true'">
				<svg:rect x="{$x}" y="{$y}" width="{$w}" height="{$h}" rx="10" ry="10" style="fill:lavender; stroke:red; stroke-width:4;"/>
			</xsl:when>
			<xsl:otherwise>
				<svg:rect x="{$x}" y="{$y}" width="{$w}" height="{$h}" rx="10" ry="10" style="fill:lavender; stroke:steelblue; stroke-width:2;"/>
			</xsl:otherwise>
		</xsl:choose>
		<svg:text  x="{$x + $w div 2}" y="{$y + $h div 2}" dx="0,0,0,0,20" dy="0,0,0,0,8" rotate="20,30,40,50,0,0,-10" 
			textLength="{$w}" lengthAdjust="spacing" font-size="16"  text-anchor="middle" fill = "navy" font-family="Arial">
			<xsl:value-of select="@name"/>
		</svg:text>
		
	</xsl:template>
	
	<xsl:template match="jpdl:task">

		<xsl:variable name="x">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="1"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="y">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="2"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="w">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="3"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="h">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="4"/>
			</xsl:call-template>
		</xsl:variable>
		
		<xsl:choose>
			<xsl:when test="@active='true'">
				<svg:rect x="{$x}" y="{$y}" width="{$w}" height="{$h}" rx="10" ry="10" style="fill:lavender; stroke:red; stroke-width:4;"/>
			</xsl:when>
			<xsl:otherwise>
				<svg:rect x="{$x}" y="{$y}" width="{$w}" height="{$h}" rx="10" ry="10" style="fill:lavender; stroke:steelblue; stroke-width:2;"/>
			</xsl:otherwise>
		</xsl:choose>

		
		<svg:text  x="{$x + $w div 2}" y="{$y + $h div 2}" dx="0,0,0,0,20" dy="0,0,0,0,8" rotate="20,30,40,50,0,0,-10" 
			textLength="{$w}" lengthAdjust="spacing" font-size="16"  text-anchor="middle" fill = "navy" font-family="Arial">
			<xsl:value-of select="@name"/>
		</svg:text>
		
	</xsl:template>	
	
	<xsl:template match="jpdl:sript">

		<xsl:variable name="x">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="1"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="y">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="2"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="w">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="3"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="h">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="4"/>
			</xsl:call-template>
		</xsl:variable>
		
		<xsl:choose>
			<xsl:when test="@active='true'">
				<svg:rect x="{$x}" y="{$y}" width="{$w}" height="{$h}" rx="10" ry="10" style="fill:lavender; stroke:red; stroke-width:4;"/>
			</xsl:when>
			<xsl:otherwise>
				<svg:rect x="{$x}" y="{$y}" width="{$w}" height="{$h}" rx="10" ry="10" style="fill:lavender; stroke:steelblue; stroke-width:2;"/>
			</xsl:otherwise>
		</xsl:choose>

		<svg:text  x="{$x + $w div 2}" y="{$y + $h div 2}" dx="0,0,0,0,20" dy="0,0,0,0,8" rotate="20,30,40,50,0,0,-10" 
			textLength="{$w}" lengthAdjust="spacing" font-size="16"  text-anchor="middle" fill = "navy" font-family="Arial">
			<xsl:value-of select="@name"/>
		</svg:text>
		
	</xsl:template>

	<xsl:template match="jpdl:sub-process">
		<xsl:variable name="x">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="1"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="y">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="2"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="w">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="3"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="h">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="4"/>
			</xsl:call-template>
		</xsl:variable>
		
		<xsl:choose>
			<xsl:when test="@active='true'">
				<svg:rect x="{$x}" y="{$y}" width="{$w}" height="{$h}" rx="10" ry="10" style="fill:lavender; stroke:red; stroke-width:4;"/>
			</xsl:when>
			<xsl:otherwise>
				<svg:rect x="{$x}" y="{$y}" width="{$w}" height="{$h}" rx="10" ry="10" style="fill:lavender; stroke:steelblue; stroke-width:2;"/>
			</xsl:otherwise>
		</xsl:choose>
		<svg:text  x="{$x + $w div 2}" y="{$y + $h div 2}" dx="0,0,0,0,20" dy="0,0,0,0,8" rotate="20,30,40,50,0,0,-10" 
			textLength="{$w}" lengthAdjust="spacing" font-size="16"  text-anchor="middle" fill = "navy" font-family="Arial">
			<xsl:value-of select="@name"/>
		</svg:text>
	</xsl:template>
	
	<xsl:template match="jpdl:hql">

		<xsl:variable name="x">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="1"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="y">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="2"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="w">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="3"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="h">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="@g"/>
				<xsl:with-param name="index" select="4"/>
			</xsl:call-template>
		</xsl:variable>
		
		<xsl:choose>
			<xsl:when test="@active='true'">
				<svg:rect x="{$x}" y="{$y}" width="{$w}" height="{$h}" rx="10" ry="10" style="fill:lavender; stroke:red; stroke-width:4;"/>
			</xsl:when>
			<xsl:otherwise>
				<svg:rect x="{$x}" y="{$y}" width="{$w}" height="{$h}" rx="10" ry="10" style="fill:lavender; stroke:steelblue; stroke-width:2;"/>
			</xsl:otherwise>
		</xsl:choose>
		<svg:text  x="{$x + $w div 2}" y="{$y + $h div 2}" dx="0,0,0,0,20" dy="0,0,0,0,8" rotate="20,30,40,50,0,0,-10" 
			textLength="{$w}" lengthAdjust="spacing" font-size="16"  text-anchor="middle" fill = "navy" font-family="Arial">
			<xsl:value-of select="@name"/>
		</svg:text>
		
	</xsl:template>
	
	<xsl:key name="dest" match="/jpdl:process/jpdl:*" use="@name"/>
	
	<xsl:template match="//jpdl:transition">
		
		<xsl:variable name="xs">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="../@g"/>
				<xsl:with-param name="index" select="1"/>
			</xsl:call-template>
		</xsl:variable>
		
		<xsl:variable name="ys">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="../@g"/>
				<xsl:with-param name="index" select="2"/>
			</xsl:call-template>
		</xsl:variable>
		
		<xsl:variable name="ws">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="../@g"/>
				<xsl:with-param name="index" select="3"/>
			</xsl:call-template>
		</xsl:variable>
		
		<xsl:variable name="hs">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="../@g"/>
				<xsl:with-param name="index" select="4"/>
			</xsl:call-template>
		</xsl:variable>
		
		<xsl:variable name="xe">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="key('dest',@to)/@g"/>
				<xsl:with-param name="index" select="1"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="ye">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="key('dest',@to)/@g"/>
				<xsl:with-param name="index" select="2"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="we">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="key('dest',@to)/@g"/>
				<xsl:with-param name="index" select="3"/>
			</xsl:call-template>
		</xsl:variable>
		<xsl:variable name="he">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str" select="key('dest',@to)/@g"/>
				<xsl:with-param name="index" select="4"/>
			</xsl:call-template>
		</xsl:variable>
		

		
		
		<xsl:variable name="eox">
			<xsl:choose>
				<xsl:when test="name(key('dest',@to))='state' or name(key('dest',@to))='sub-process' or name(key('dest',@to))='hql' ">
					<xsl:value-of select="$we div 2"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="'20'"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		
		<xsl:variable name="eoy">
			<xsl:choose>
				<xsl:when test="name(key('dest',@to))='state' or name(key('dest',@to))='sub-process' or name(key('dest',@to))='hql' ">
					<xsl:value-of select="$he div 2"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="'20'"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="sox">
			<xsl:choose>
				<xsl:when test="name(..)='state' or name(..)='sub-process' or name(..)='hql' ">
					<xsl:value-of select="$ws div 2"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="'20'"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		
		<xsl:variable name="soy">
			<xsl:choose>
				<xsl:when test="name(..)='state' or name(..)='sub-process' or name(..)='hql' ">
					<xsl:value-of select="$hs div 2"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="'20'"/>					
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		
		<xsl:variable name="tmp">
			<xsl:call-template name="splitByComma">
				<xsl:with-param name="str"><xsl:value-of select="substring-before(@g,':')"/></xsl:with-param>
				<xsl:with-param name="worddiv" select="';'"/>
			</xsl:call-template>			
		</xsl:variable>

		<xsl:variable name="tmp_x">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str">
					<xsl:call-template name="tokinazeAndLast">
						<xsl:with-param name="str"><xsl:value-of select="substring-before(@g,':')"/></xsl:with-param>
						<xsl:with-param name="worddiv" select="';'"/>
					</xsl:call-template>
				</xsl:with-param>
				<xsl:with-param name="index" select="1"/>
			</xsl:call-template>
		</xsl:variable>

		<xsl:variable name="tmp_y">
			<xsl:call-template name="tokinazeAndAtIndex">
				<xsl:with-param name="str">
					<xsl:call-template name="tokinazeAndLast">
						<xsl:with-param name="str"><xsl:value-of select="substring-before(@g,':')"/></xsl:with-param>
						<xsl:with-param name="worddiv" select="';'"/>
					</xsl:call-template>
				</xsl:with-param>
				<xsl:with-param name="index" select="2"/>
			</xsl:call-template>
		</xsl:variable>

		<svg:path d="M{$xs + $sox},{$ys + $soy}
		 			{translate(substring-before(@g,':'),';',' ')}
					{$xe + $eox},{$ye + $eoy}" style="stroke:green;" fill="none" stroke-width="3"
					marker-end="url(#Triangle)"/>
		
		<svg:path d="M{$xs + $sox},{$ys + $soy} 
		 			{$tmp_x},{$tmp_y} 
					{$xe + $eox},{$ye + $eoy}" style="stroke:red;" fill="none" stroke-width="3"
					marker-end="url(#Triangle)"/>

	</xsl:template>
	
	<xsl:template name="tokinazeAndAtIndex">
		<xsl:param name="str" select="."/>
		<xsl:param name="worddiv" select="','"/>
		<xsl:param name="index"/>
        <xsl:choose>
        	<xsl:when test="string-length($str)=0">
        	</xsl:when>
			<xsl:when test="$index>1 and contains($str,$worddiv)">
				<xsl:call-template name="tokinazeAndAtIndex">
					<xsl:with-param name="str" select="substring-after($str,$worddiv)"/>
					<xsl:with-param name="index" select="$index - 1"/>
					<xsl:with-param name="worddiv" select="$worddiv"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="$index=1 and contains($str,$worddiv)">
				<xsl:value-of select="substring-before($str,$worddiv)"/>
			</xsl:when>
			<xsl:when test="$index=1 and not(contains($str,$worddiv))">
				<xsl:value-of select="$str"/>
			</xsl:when>
			<xsl:otherwise>
				== error: i=<xsl:value-of select="$index"/> s=<xsl:value-of select="$str"/> d=<xsl:value-of select="$worddiv"/> ==
			</xsl:otherwise>
        </xsl:choose>
    </xsl:template>
  	
  	<xsl:template name="tokinazeAndLast">
		<xsl:param name="str" select="."/>
		<xsl:param name="worddiv" select="','"/>
        <xsl:choose>
        	<xsl:when test="string-length($str)=0"/>
			<xsl:when test="contains($str,$worddiv)">
				<xsl:call-template name="tokinazeAndLast">
					<xsl:with-param name="str" select="substring-after($str,$worddiv)"/>
					<xsl:with-param name="worddiv" select="$worddiv"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="not(contains($str,$worddiv))">
				<xsl:value-of select="$str"/>
			</xsl:when>
			<xsl:otherwise>
				== error: s=<xsl:value-of select="$str"/> d=<xsl:value-of select="$worddiv"/> ==
			</xsl:otherwise>
        </xsl:choose>
    </xsl:template>
  	
  	<xsl:template name="splitByComma">
		<xsl:param name="str" select="."/>
		<xsl:param name="worddiv" select="','"/>
        <xsl:choose>
			<xsl:when test="contains($str,$worddiv)">
				<part><xsl:value-of select="substring-before($str,$worddiv)"/></part>
				<xsl:call-template name="splitByComma">
					<xsl:with-param name="str" select="substring-after($str,$worddiv)"/>
					<xsl:with-param name="worddiv" select="$worddiv"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:otherwise>
				<part><xsl:value-of select="$str"/></part>
			</xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    
</xsl:stylesheet>



 
